package com.selfdriving.adapter;

import java.util.List;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.selfdriving.R;

public class GroupAdapter extends BaseAdapter {
	private Context context;

	private List<String> names;

	private HolderView holderView;

	public GroupAdapter(Context context, List<String> names) {
		this.context = context;
		this.names = names;
	}

	@Override
	public int getCount() {
		return names.size();
	}

	@Override
	public Object getItem(int poistion) {
		return names.get(poistion);
	}

	@Override
	public long getItemId(int poistion) {
		return poistion;
	}

	@Override
	public View getView(int poistion, View view, ViewGroup arg2) {
		String  name = names.get(poistion);
		if (view == null) {
			holderView = new HolderView();
			view = ((LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
					.inflate(R.layout.group_item, null);
			view.setTag(holderView);
		} else {
			holderView = (HolderView) view.getTag();
		}
		holderView.name = (TextView) view.findViewById(R.id.tvName);
		holderView.name.setText(name);
		return view;
	}

	private class HolderView {
		private TextView name;

	}

}

